<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="middle"></div>
<span></span>
<ul id="ul">
    <li>1</li>
    <li>2</li>
    <li class=" middle">
        aaa
        <span></span>
    </li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
</ul>
</body>
<script>
    $("#ul .middle").innerHTML = "我写出来了啊，有什么奖励么"
    //    $() documet.querySelectorAll()
    function $(ele, parent) {
        if (ele.indexOf(" ") != -1) {
            var list = ele.split(" ")//[#ul,.middle]
            var pa = null;
            for (let i = 0; i < list.length; i++) {
//                pa = document||pa;
//                console.log(pa);
//                if (!pa) {
//                    pa = document;
//                }
                pa = pa || document;
                pa = $(list[i], pa);
            }
            return pa
        } else {
            parent = parent || document;
            var firstCode = ele.charAt(0);
            var ele1 = ele.substring(1);
            if (firstCode == "#") {
                return parent.getElementById(ele1);
            }
            if (firstCode == ".") {
                return parent.getElementsByClassName(ele1)[0];
            } else {
                return parent.getElementsByTagName(ele)[0];
            }
        }
    }
</script>
</html>